package cn.merryyou.security.config;

import org.assertj.core.util.Lists;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.access.AccessDecisionVoter;
import org.springframework.security.access.vote.AffirmativeBased;
import org.springframework.security.access.vote.AuthenticatedVoter;
import org.springframework.security.access.vote.RoleVoter;

import java.util.List;

/**
 * @author YuanYifeng
 * @description: TODO
 * @date 2019/4/23 12:45
 */
@Configuration
public class SecurityCompent {

    /**
     * 授权决策器
     * @return
     */
    @Bean
    public AffirmativeBased CustomAffirmativeBased() {
        List<AccessDecisionVoter<? extends Object>> list= Lists.newArrayList();
        RoleVoter voter=new RoleVoter();
        voter.setRolePrefix("");
        list.add(voter);
        list.add(new AuthenticatedVoter());
        return new AffirmativeBased(list);
    }

}
